/**
 * 前端路由
 */

var express = require("express");
var router = express.Router();

const commonController = require("@/controllers/v1/common-controller");
const commonValidate = require("@/validates/v1/common-validate");
const multerUpload = require("@/utils/upload");

router.get("/captcha", commonController.captcha);
router.get("/login", commonValidate.login, commonController.login);
router.get("/login-wx", commonValidate.loginWx, commonController.loginWx);
router.post("/refresh-token", commonController.refreshToken);
router.get("/bind-wx", commonController.bindWx);
router.get("/member", commonController.member);
router.post(
  "/upload/image",
  multerUpload.single("file"),
  commonController.uploadImage
);

// 事件
const thingController = require("@/controllers/v1/thing-controller");
const thingValidate = require("@/validates/v1/thing-validate");
router.get("/things", thingController.page);
router.post("/things", thingValidate.create, thingController.create);
router.post("/things/batch", thingController.createBatch);

// 事件快捷选项
const thingOptionController = require("@/controllers/v1/thing-option-controller");
const thingOptionValidate = require("@/validates/v1/thing-option-validate");
router.get("/thing-options", thingOptionController.list);
router.post(
  "/thing-options",
  thingOptionValidate.create,
  thingOptionController.create
);
router.put(
  "/thing-options/:id",
  thingOptionValidate.create,
  thingOptionController.update
);
router.get("/thing-options/:id", thingOptionController.detail);

// 统计
const statisticController = require("@/controllers/v1/statistic-controller");
router.get("/statistic/today", statisticController.today);

module.exports = router;
